<template>
  <div class="configDetail">
    <van-nav-bar
      :title="$route.meta.title"
      left-arrow
      :border="false"
      @click-left="clickLeft"
      class="nav-bar"
    >
    </van-nav-bar>
    <div
      style="
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 10px 0;
      "
    >
      <van-tag plain type="primary" style="margin: 10px 10px 10px 20px"
        >基本信息</van-tag
      >
      <div
        style="
          display: flex;
          justify-content: space-between;
          align-items: center;
        "
      >
        <van-button
          type="info"
          size="small"
          @click="editData()"
          style="margin-right: 20px"
          >一键反填</van-button
        >
        <!--<van-button
          type="info"
          size="small"
          @click="quoteData()"
          style="margin-right: 20px"
          >引用</van-button
        > -->
        <van-button
          type="info"
          size="small"
          @click="saveItemData()"
          style="margin-right: 20px"
          >保存</van-button
        >
        <van-button
          type="info"
          size="small"
          @click="getPDF1()"
          style="margin-right: 20px"
          >PDF预览</van-button
        >
        <van-button
          type="info"
          size="small"
          @click="submitItemData()"
          style="margin-right: 25px"
          >递交</van-button
        >
      </div>
    </div>
    <van-row type="flex">
      <van-col span="12" class="readonly">
        <van-field
          v-model="treeNode.projectName"
          label="项目"
          input-align="center"
          readonly
        >
        </van-field>
      </van-col>
      <van-col span="12" class="readonly">
        <van-field
          v-model="treeNode.testID"
          label="检验单号"
          input-align="center"
          readonly
        >
        </van-field>
      </van-col>
      <van-col span="12">
        <van-field
          readonly
          clickable
          label="检验记录"
          v-model="recordName"
          placeholder="请选择"
          @click="showPicker = true"
          class="select-record"
          input-align="center"
        />
      </van-col>
      <van-col span="12" class="readonly">
        <van-field v-model="state" label="状态" input-align="center" readonly>
        </van-field>
      </van-col>
      <van-col span="12" class="readonly" v-if="state == '驳回'">
        <van-field
          v-model="reason"
          label="驳回理由"
          input-align="center"
          readonly>
        </van-field>
      </van-col>
    </van-row>
    <van-row
      class="cd-content"
      type="flex"
      align="center"
      justify="space-between"
    >
      <van-col span="12" v-show="recordShow" class="van-col">
        <div class="title">
          <span>检验记录</span>
          <van-icon
            class="recordIcon"
            name="expand-o"
            @click="showModel('recordIcon')"
          />
        </div>
        <!-- <div id="recordPdf"></div> -->
        <HPDFViewer :path="pdfUrl" />
      </van-col>
      <van-col span="12" v-show="itemShow" class="van-col">
        <div class="title">
          <span>检验项目</span>
          <!-- <div @click="openScan('3')">
           
            <van-icon name="scan" size="20" />
          </div> -->
          <van-icon
            class="itemIcon"
            name="expand-o"
            @click="showModel('itemIcon')"
          />
        </div>
        <div id="conList" v-html="itemHtm"></div>
      </van-col>
    </van-row>

    <van-popup
      v-model="showPicker"
      :style="{ height: '50%' }"
      position="bottom"
      get-container="body"
      :lock-scroll="false"
    >
      <van-cascader
        :style="{ height: '100%' }"
        v-model="cascaderValue"
        :options="options"
        @close="showPicker = false"
        @finish="onFinish"
        :field-names="fieldNames"
      />
    </van-popup>
    <!-- <van-popup
      v-model="showSamplePicker"
      :style="{ height: '50%' }"
      position="bottom"
      get-container="body"
      :lock-scroll="false"
    >
      <van-cascader
        :style="{ height: '100%' }"
        v-model="sampleValue"
        :options="sampleArr"
        @close="showSamplePicker = false"
        @finish="onSampleFinish"
        :field-names="sampleNames"
      />
    </van-popup> -->

    <van-popup
      v-model="PDFShow"
      position="left"
      :style="{ width: '60%', height: '100%' }"
    >
      <van-row
        type="flex"
        align="center"
        justify="space-between"
        class="van-row-style"
      >
        <van-col
          span="14"
          class="van-col-style"
          style="
            display: flex;
            align-items: center;
            justify-content: space-between;
          "
        >
          <div style="display: flex; align-items: center">
            <span style="white-space: nowrap">PDF上传：</span>
          </div>
          <van-dropdown-menu>
            <van-dropdown-item v-model="attachmentId" :options="pdfArr" />
          </van-dropdown-menu>
          <van-button type="primary" size="small" @click="delPdfList()"
            >删除</van-button
          >
        </van-col>

        <van-col
          span="10"
          class="van-col-style"
          style="
            display: flex;
            align-items: center;
            justify-content: space-between;
          "
        >
          <van-uploader
            :max-count="1"
            :after-read="afterRead"
            accept=".pdf,.PDF"
          >
            <van-button icon="plus" type="primary" size="small"
              >上传</van-button
            >
          </van-uploader>
          <van-button
            class="van-col-btn"
            type="primary"
            size="small"
            @click="getPdfData()"
            style="margin-left: 10px"
            >一键赋值</van-button
          >
          <van-button
            class="van-col-btn"
            type="primary"
            size="small"
            @click="assignPdfData()"
            >确定</van-button
          >
        </van-col>
      </van-row>
      <van-row
        class="cd-content"
        type="flex"
        align="center"
        justify="space-between"
      >
        <van-col span="12" class="van-col">
          <div class="title">
            <span>检验记录</span>
          </div>
          <HPDFViewer :path="uploadPdfUrl" />
        </van-col>
        <van-col span="12" class="van-col">
          <div class="title">
            <span>检验项目</span>
            <span class="itemIcon"
              ><input
                type="checkbox"
                style="width: 20px; height: 20px"
              />全选</span
            >
          </div>
          <div id="PDFList" v-html="pdfHtm"></div>
        </van-col>
      </van-row>
    </van-popup>

    <van-popup
      v-model="PDFShow1"
      position="left"
      :style="{ width: '60%', height: '100%' }"
    >
      <van-row
        class="cd-content"
        type="flex"
        align="center"
        justify="space-between"
      >
        <van-col span="24" class="van-col">
          <!-- <div id="uploadPdf1"></div> -->
          <HPDFViewer :path="previewPdfUrl" />
        </van-col>
      </van-row>
    </van-popup>

    <div class="scan" v-if="scanShow">
      <div id="bcid">
        <div style="height: 40%"></div>
        <p class="tip">...载入中...</p>
      </div>
      <footer>
        <button @click="closeModel">退出</button>
      </footer>
    </div>

    <van-popup
      v-model="showItem"
      position="bottom"
      :style="{ height: '50%' }"
      @close="closePopup"
      get-container="body"
    >
      <div class="van-picker__toolbar">
        <button type="button" class="van-picker__cancel" @click="cancel">
          取消
        </button>
        <button type="button" class="van-picker__confirm" @click="onConfirm">
          确认
        </button>
      </div>
      <div class="checkbox-con" style="overflow-y: auto">
        <van-cell title="全选">
          <template #right-icon>
            <van-checkbox
              name="all"
              @click="toggleAll"
              shape="square"
              v-model="checkedAll"
            />
          </template>
        </van-cell>
        <van-checkbox-group v-model="checkBoxArr" ref="checkboxGroup">
          <van-cell-group>
            <van-cell
              v-for="(item, index) in columns"
              clickable
              v-model="columns[index]"
              :key="columns[index]"
            >
              <template #right-icon>
                <van-checkbox
                  :name="columns[index]"
                  shape="square"
                  ref="checkboxes"
                />
              </template>
            </van-cell>
          </van-cell-group>
        </van-checkbox-group>
      </div>
    </van-popup>

    <van-popup
      v-model="showSingle"
      get-container="body"
      position="bottom"
      :style="{ height: '50%' }"
    >
      <van-picker
        show-toolbar
        :columns="singleColumns"
        @cancel="showSingle = false"
        @confirm="onConfirmSingle"
      />
    </van-popup>

    <van-popup
      v-model="showQuote"
      safe-area-inset-bottom
      get-container="body"
      position="left"
      style="width: 80vw; height: 100% !important"
    >
      <div class="popup-content__title">
        <div class="title">记录引用</div>
      </div>
      <div class="popup-content">
        <div class="popup-content__content">
          <van-row>
            <van-col span="12">
              <van-field
                v-model="quote_materialType"
                name="quote_materialType"
                label="检品类型"
                required
                input-align="center"
                :rules="[{ required: true, message: '请选择检品类型' }]"
              >
                <template #input>
                  <material-type v-model="quote_materialType" />
                </template>
              </van-field>
            </van-col>
            <van-col span="12">
              <van-field
                v-model="quote_materialCode"
                name="quote_materialCode"
                label="检品名称"
                required
                input-align="center"
                :rules="[{ required: true, message: '请选择检品名称' }]"
              >
                <template #input>
                  <material-name
                    :materialType="quote_materialType"
                    v-model="quote_materialCode"
                  />
                </template>
              </van-field>
            </van-col>
            <van-col span="12">
              <van-field
                v-model="quote_batchID"
                name="quote_batchID"
                label="批号"
                required
                clickable
                input-align="center"
                :rules="[{ required: true, message: '请输入批号' }]"
              >
                <template #input>
                  <batch-list-quote
                    v-model="quote_batchID"
                    :materialCode="quote_materialCode"
                  >
                  </batch-list-quote>
                </template>
              </van-field>
            </van-col>
            <van-col span="12">
              <van-field
                v-model="quote_testID"
                name="quote_testID"
                label="检验编号"
                required
                readonly
                input-align="center"
                @click="showTest = true"
                :rules="[{ required: true, message: '请选择检验编号' }]"
              >
              </van-field>
            </van-col>
          </van-row>
          <div
            style="display: flex; justify-content: flex-end; padding: 10px 25px"
          >
            <van-button
              plain
              v-if="!showBtn"
              name="search"
              size="small"
              type="info"
              @click="handleSearch()"
              >查询</van-button
            >
            <van-button
              plain
              name="check"
              size="small"
              v-if="showBtn"
              type="primary"
              @click="handleSave()"
              >保存</van-button
            >
          </div>
        </div>
      </div>
      <div class="popup-content__footer">
        <!-- <textarea name="" cols="30" rows="8"></textarea> -->
        <ul class="searchDetail" v-html="liHtml"></ul>
      </div>
    </van-popup>
    <van-popup
      v-model="showTest"
      round
      position="bottom"
      :style="{ height: '50%' }"
    >
      <van-picker
        show-toolbar
        :columns="testList"
        @cancel="showTest = false"
        @confirm="onConfirmTest"
      />
    </van-popup>
  </div>
</template>

<script type="text/ecmascript-6">
import HPDFViewer from "@/components/HPDFViewer";

import {
  deleteEquipFile,
  GetBatchReportData,
  GetCalculateResult,
  GetClassUserSelect,
  GetClassUserSelectThree,
  getConfigAttributesText,
  getEquipmentFileSelect,
  GetLogicResult,
  GetRecordReportActiveTree,
  GetRecordReportDataTwo,
  getReportId,
  getTestByTestId,
  getTestTree,
  GetUserInfo,
  PreviewElectronicRecordModel,
  PreviewElectronicRecordReport,
  ReturnDJData,
  SaveRecordReportData,
  SubmitRecordApprove,
  uploadEquipmentFile,
} from "@/api/base";
import {
  GetRecordReportAttributes,
  UpdateSamplePlaninfoAttribute,
  GetRecordReportData,
} from "@/api/microBial";
import { GetAttributeValue } from "@/api/check";
import MaterialName from "@/components/MaterialName";
import MaterialType from "@/components/MaterialType";
import {
  Button,
  Calendar,
  cascader,
  Cell,
  CellGroup,
  Checkbox,
  CheckboxGroup,
  Col,
  DropdownItem,
  DropdownMenu,
  Field,
  Icon,
  NavBar,
  Notify,
  Picker,
  Popup,
  Row,
  Tabbar,
  TabbarItem,
  Tag,
  Uploader,
} from "vant";
import BatchListQuote from "./BatchListQuote.vue";

import { to } from "@/utils";
import $ from "jquery";
import Pdfh5 from "pdfh5";
import "pdfh5/css/pdfh5.css";
let scan = null;
export default {
  name: "waterWaitForInspectionDetail",
  components: {
    HPDFViewer,
    [Tabbar.name]: Tabbar,
    [TabbarItem.name]: TabbarItem,
    [NavBar.name]: NavBar,
    [Icon.name]: Icon,
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
    [Col.name]: Col,
    [Row.name]: Row,
    [Button.name]: Button,
    [Popup.name]: Popup,
    [Field.name]: Field,
    [Calendar.name]: Calendar,
    [Notify.name]: Notify,
    [Uploader.name]: Uploader,
    [DropdownMenu.name]: DropdownMenu,
    [DropdownItem.name]: DropdownItem,
    [Checkbox.name]: Checkbox,
    [CheckboxGroup.name]: CheckboxGroup,
    [Picker.name]: Picker,
    [cascader.name]: cascader,
    [Tag.name]: Tag,
    MaterialType,
    MaterialName,
    BatchListQuote,
  },
  data() {
    return {
      token: "",
      gDomain: "",
      value: "",
      pdfUrl: "",
      showPicker: false,
      recordName: "",
      options: [],
      params: "",
      mCode: "",
			uploadPdfUrl: "",
      materialCode: "",
      materialName: "",
      batchID: "",
      standardBaseOn: "",
      testStandard: "",
      recordCode: "",
      pdfUrl: "",
      cascaderValue: "",
      fieldNames: {
        text: "name",
        value: "code",
      },
      previewPdfUrl: "",
      pdfh5: null,
      type: {
        Varchar: false,
      },
      itemHtm: "",
      itemDataArr: [],
      codeUrl: "",
      scanShow: false,
      scanCode: "",
      dataVal: "",
      recordShow: true,
      itemShow: true,
      sampleName: "", //合并后检验样品
      showSamplePicker: false,
      sampleArr: [],
      sampleValue: "",
      sampleNames: {
        text: "name",
        value: "code",
      },
      totalData: {},
      timer: null,
      timer1: null,
      scanType: "",
      scanObj: {},
      PDFShow: false,
      PDFShow1: false,
      pdfName: "",
      pdfArr: [],
      attachmentId: "",
      pdfHtm: "",
      reason: "",
      //复选弹窗
      showItem: false,
      checkBoxArr: [],
      columns: [],
      checkedAll: false,
      checkBoxName: "",
      //
      dataCode: "",
      //单选弹窗
      showSingle: false,
      singleColumns: [],
      showEquipType: "",
      treeNode: "", //待我检验点击树信息
      state: "", //检验状态
      quote_materialType: "",
      quote_materialCode: "",
      quote_batchID: "",
      quote_testID: "",
      showTest: false,
      testList: [],
      showQuote: false,
      showBtn: false,
      liHtml: "",
      quoteDataArr: [],
    };
  },
  watch: {
    attachmentId(val) {
      this.showUploadPdf();
    },
    quote_batchID(val) {
      if (val) {
        this.getTestId();
      }
    },
  },
  mounted() {
    this.gDomain = localStorage.getItem("domainKey");
    this.token = localStorage.getItem("tokenKey");
    // this.getSampleData();
    this.fetchItems();
    // debugger
    console.log(this.$route);
  },
  methods: {
    clickLeft() {
      if (scan && scan != "") {
        scan.close();
      }
      this.$router.replace({ name: "waterWaitForInspection" });
    },
    async getSampleData() {
      var that = this;
      var queryParams = {
        pageModel: { Search: [30, "UrgencyDegree"], Token: this.token },
      };
      const [err, res] = await to(getTestTree(queryParams));
      if (err) return;
      var result = res.Result;
      this.dowhile(result);
      this.sampleArr = result;
    },
    // onSampleFinish({ selectedOptions }) {
    //   this.showSamplePicker = false;
    //   var len = selectedOptions.length;
    //   var toDetail = selectedOptions[len - 1];
    //   this.sampleName = toDetail.name;
    //   this.mCode = toDetail.code;
    //   this.materialName = toDetail.materialName;
    //   this.batchID = toDetail.batchID;
    //   this.standardBaseOn = toDetail.standardBaseOn;
    //   this.materialCode = toDetail.materialCode;
    //   this.testStandard = toDetail.testStandard;
    // },
    onFinish({ selectedOptions }) {
      this.showPicker = false;
      var len = selectedOptions.length;
      var toDetail = selectedOptions[len - 1];
      this.recordName = toDetail.name;
      this.recordCode = toDetail.code;
      this.handlePdf();
      this.handleItem();
    },
    dowhile(b) {
      for (var i = 0; i < b.length; i++) {
        if (b[i].children && b[i].children.length > 0) {
          this.dowhile(b[i].children);
        } else {
          delete b[i].children;
        }
      }
    },
    fetchItems() {
      var that = this;
      var queryParams = {
        materialCode: this.treeNode.code,
        StandardCode: this.treeNode.standardCode,
        Token: this.token,
        TestID:this.treeNode.testID,
      };
      // const [err, res] = await to(GetRecordReportActiveTree(queryParams));
      // if (err) return;
      GetRecordReportActiveTree(queryParams).then((res) => {
        if (res.ErrorCode == 0) {
          var result = res.Result;
          if (!result || result.length == 0) return false;
          that.dowhile(result);
          that.options = result;
        }
      });
    },
    handlePdf() {
      var that = this;
      this.pdfh5 = null;
      var queryParams = {
        recordCode: this.recordCode,
        Token: this.token,
      };
      // const [err, res] = await to(PreviewElectronicRecordModel(queryParams));
      // if (err) return;
      PreviewElectronicRecordModel(queryParams).then((res) => {
        console.log(12);
        if (res.ErrorCode == 0) {
          var targetPath = res.Result.targetPath;
          // that.pdfUrl = that.gDomain + targetPath;
          this.pdfUrl = targetPath;
        }
      });
    },
    handleItem() {
      var that = this;
      var queryParams = {
        recordCode: that.recordCode,
        testID: this.treeNode.testID,
        testStandard: this.treeNode.standardCode,
        Token: this.token,
      };
      // const [err, res] = await to(GetRecordReportAttributes(queryParams));
      // if (err) return;
      GetRecordReportAttributes(queryParams).then((res) => {
        if (res.ErrorCode == 0) {
          var htm = "";
          var result = res.Result;
          if (result && result.length > 0) {
            that.itemDataArr = result;
            result.map((item, index) => {
              if (item.type == "Varchar") {
                if (item.wordCode == "${B1}") {
                  htm +=
                    "<div class='listDetail'><div>" +
                    item.wordCode +
                    ":" +
                    item.name +
                    "</div>";
                  htm +=
                    "<div class='listValue'>值：<input dataCode=" +
                    item.code +
                    "  name='Varchar'  class='" +
                    item.code +
                    "' type='text' dataName='" +
                    item.name +
                    "' datatype='" +
                    item.type +
                    "' ><span>" +
                    item.unit +
                    "</span><button class='Varchar' style='width:40%'>一键赋值</button></div>";
                  htm += "</div>";
                } else {
                  htm +=
                    "<div class='listDetail'><div>" +
                    item.wordCode +
                    ":" +
                    item.name +
                    "</div>";
                  htm +=
                    "<div class='listValue'>值：<input dataCode=" +
                    item.code +
                    " name='Varchar' class='" +
                    item.code +
                    "' type='text' dataName='" +
                    item.name +
                    "'><span>" +
                    item.unit +
                    "</span><button class='Varchar2' dataVal=" +
                    JSON.stringify(item.data) +
                    " style='width:20%'>选择</button></div>";
                  htm += "</div>";
                }
              } else if (item.type == "DataInterchange") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue'>值：<input dataCode=" +
                  item.code +
                  "  name='DataInterchange'  class='" +
                  item.code +
                  "' type='text' dataName='" +
                  item.name +
                  "'><span>" +
                  item.unit +
                  "</span><button class='DataInterchange' style='width:40%'>一键赋值</button></div>";
                htm += "</div>";
              } else if (item.type == "Radio") {
                htm += `
                <div class='listDetail'>
                  <div>${item.wordCode}:${item.name}</div>
                  <div class='listValue'>
                    值：<input name='Radio' dataVal='${JSON.stringify(item.data)}' dataCode='${item.code}' datatype='${item.type}' value="请选择"  class='radioSelect ${item.code}' dataId='/' type='text' readonly dataName='${item.name}'>
                  </div>
                </div>
              `;
              } else if (item.type == "Float") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue formulaOne formulaTwo'>值：<input dataCode=" +
                  item.code +
                  " name='Float' class=" +
                  item.code +
                  " type='text' dataName='" +
                  item.name +
                  "'><span>" +
                  item.unit +
                  "</span></div>";
                htm += "</div>";
              } else if (item.type == "Weight") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue formulaOne formulaTwo'>值：<input dataCode=" +
                  item.code +
                  " name='Weight' class=" +
                  item.code +
                  " type='text' readonly dataName='" +
                  item.name +
                  "'><span>" +
                  item.unit +
                  "</span></div>";
                htm += "</div>";
              } else if (item.type == "Choose") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue'>值：<input  name='Choose' dataVal=" +
                  JSON.stringify(item.data) +
                  " dataCode=" +
                  item.code +
                  " class='multSelect' type='text' dataName='" +
                  item.name +
                  "'><span>" +
                  item.unit +
                  "</span></div>";
                htm += "</div>";
              } else if (item.type == "Date") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue'>值：<input dataCode=" +
                  item.code +
                  " name='Date' class=" +
                  item.code +
                  " type='text' readonly dataName='" +
                  item.name +
                  "'><span>" +
                  item.unit +
                  "</span><button class='Date' data-val='" +
                  item.data[0] +
                  "' style='width:40%'>一键赋值</button></div>";
                htm += "</div>";
              } else if (item.type == "Scan") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue'>值：<input dataCode=" +
                  item.code +
                  " name='Scan' class=" +
                  item.code +
                  " type='text' dataName='" +
                  item.name +
                  "'><button class='Scan' data-val='" +
                  JSON.stringify(item.data) +
                  "' >扫码</button></div>";
                htm += "</div>";
              } else if (item.type == "Calculate") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue formulaOne formulaTwo'>值：<input dataCode=" +
                  item.code +
                  " name='Calculate' class=" +
                  item.code +
                  " type='text' dataName='" +
                  item.name +
                  "'><span>" +
                  item.unit +
                  "</span><button class='Calculate'>计算</button></div>";
                htm += "</div>";
              } else if (item.type == "BoolResult") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue formulaTwo'>值：<input dataCode=" +
                  item.code +
                  " name='BoolResult' class=" +
                  item.code +
                  " type='text' dataName='" +
                  item.name +
                  "'><span>" +
                  item.unit +
                  "</span><button class='BoolResult'>计算</button></div>";
                htm += "</div>";
              } else if (item.type == "Select") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                if (item.data[0] == "user") {
                  htm +=
                    "<div class='listValue'>值：<input type='user' dataCode=" +
                    item.code +
                    " name='Select' class=" +
                    item.code +
                    " type='text' dataId='' dataName='" +
                    item.name +
                    "' datatype='" +
                    item.type +
                    "'><button class='Select' >检测员</button></div>";
                } else if (item.data[0] == "team") {
                  htm +=
                    "<div class='listValue'>值：<input name='Select' dataCode=" +
                    item.code +
                    "  class='singleSelect " +
                    item.code +
                    "' dataId='' type='text' dataVal='team' readonly dataName='" +
                    item.name +
                    "' datatype='" +
                    item.type +
                    "'></div>";
                } else {
                  htm +=
                    "<div class='listValue'>值：<input name='Select' dataCode=" +
                    item.code +
                    "  class='singleSelect " +
                    item.code +
                    "' dataId='' type='text' readonly dataName='" +
                    item.name +
                    "' datatype='" +
                    item.type +
                    "'></div>";
                }

                htm += "</div>";
              } else if (item.type == "PDF") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue mainPdf formulaOne formulaTwo'>值：<input dataCode=" +
                  item.code +
                  " name='PDF' class=" +
                  item.code +
                  " type='text' dataName='" +
                  item.name +
                  "'></div>";
                htm += "</div>";
              } else if (item.type == "AutoCoding") {
                htm +=
                  "<div class='listDetail'><div>" +
                  item.wordCode +
                  ":" +
                  item.name +
                  "</div>";
                htm +=
                  "<div class='listValue formulaOne formulaTwo'>值：<input dataCode=" +
                  item.code +
                  " name='AutoCoding' class=" +
                  item.code +
                  " type='text' readonly dataName='" +
                  item.name +
                  "'><span>" +
                  item.unit +
                  "</span></div>";
                htm += "</div>";
              }
            });
          }
          that.itemHtm = htm;
          that.getRecordReportData();
        }
      });

      $("#conList").on("click", ".multSelect", function () {
        that.checkBoxArr = [];
        
        var dataVal = JSON.parse(this.attributes[1].value);
        that.dataCode = this.attributes[2].value;
        that.columns = dataVal;
        that.showItem = true;
      });

      $("#conList").on("click", ".singleSelect", function () {
        that.dataCode = this.attributes[1].value;
        var dataVal = this.getAttribute("dataval");
        if (dataVal && dataVal == "team") {
          var result = { pageModel: { Token: that.token } };
          GetClassUserSelectThree(result).then(function (response) {
            var res = response.Result;
            if (response.ErrorCode == 0) {
              if (res && res.length > 0) {
                that.singleColumns = res;
                that.showSingle = true;
              }
            }
          });
        } else {
          var result = {
            pageModel: { Token: that.token },
          };
          GetClassUserSelect(result).then(function (response) {
            var res = response.Result;
            if (response.ErrorCode == 0) {
              if (res && res.length > 0) {
                that.singleColumns = res;
                that.showSingle = true;
              }
            }
          });
        }
      });

      $("#conList").on("click", ".radioSelect", function () {
        console.log('this.attributes[1].value',this.attributes[1].value)
        var dataVal = JSON.parse(this.attributes[1].value);
        that.dataCode = this.attributes[2].value;
        if (dataVal && dataVal.length) {
          var radioDataArr = [];
          dataVal.map((item) => {
            radioDataArr.push({
              value: item,
              text: item,
            });
          });
          radioDataArr.unshift({
            value: "/",
            text: "请选择",
          });
          that.singleColumns = radioDataArr;
          that.showSingle = true;
        }
      });

      $("#conList").on("click", "button.Varchar2", function () {
        var dataVal = JSON.parse(this.attributes[1].value);
        that.dataCode = $(this).siblings("input")[0].classList.value;
        if (dataVal && dataVal.length > 0) {
          that.singleColumns = dataVal;
          that.showSingle = true;
        }
      });

      $("[name=Varchar]").on("input", function () {
        var valThis = $(this).val();
        if (valThis == "\\") {
          $(this).val("");
          Notify({ type: "danger", message: "请勿输入\\" });
        }
      });

      $("#conList").on("click", "button.Varchar", function () {
        var thisVal = $(this).siblings("input").val();
        var thisCode = $(this).siblings("input")[0].classList.value;
        var q = {
          batchID: thisVal,
          recordCode: that.recordCode,
          Token: that.token,
        };

        GetBatchReportData(q).then(function (response) {
          var res = response.Result;
          if (response.ErrorCode == 0) {
            if (res.data.length == 0) {
              Notify({ type: "danger", message: "当前批号无数据" });
              return false;
            } else {
              res.data.map((item) => {
                if (thisCode != item.attributeCode)
                  $("." + item.attributeCode).val(item.attributeValue);
              });
            }
          }
        });
      });

      $("#conList").on("click", "button.DataInterchange", function () {
        // var thisVal = $(this).siblings("input").val();
        // var thisCode = $(this).siblings("input")[0].classList.value;

        var q = {
          TestID: that.mCode,
          RecordCode: that.recordCode,
          Token: that.token,
        };
        ReturnDJData(q).then(function (response) {
          var res = response.Result;
          if (response.ErrorCode == 0) {
            res.map((item) => {
              $("." + item.AttributeCode).val(item.AttributeValue);
            });
          }
        });
      });

      $("#conList").on("click", "button.Select", function () {
        var _that = this;
        var a = { value: "user", url: "API/BaseData/GetUserInfo", ajax: "get" };
        var result = {
          Token: that.token,
        };
        GetUserInfo(result).then(function (res) {
          if (res.ErrorCode == 0) {
            var userName = res.Result.userName;
            var userID = res.Result.userID;
            $(_that).siblings("input").attr("dataId", userID);
            $(_that).siblings("input").val(userName);
          }
        });
      });
      $("#conList").on("click", "button.Calculate", function () {
        var _that = this;
        var thisCode = $(this).siblings("input")[0].classList.value;
        var formulaArr = [];
        var inputArr = $(".formulaOne input");
        inputArr.each((index, item1) => {
          var formulaJson = {};
          formulaJson["code"] = item1.classList.value;
          formulaJson["value"] = item1.value * 1;
          formulaArr.push(formulaJson);
        });
        var result = {
          Token: that.token,
          attributeConfigCode: thisCode,
          attributes: formulaArr,
          batchID: that.batchID,
        };
        GetCalculateResult(result)
          .then(function (res) {
            if (res.ErrorCode == 0) {
              var result = res.Result;
              $(_that).siblings("input").val(result);
            } else {
              Notify({ type: "danger", message: res.ErrorMsg });
            }
          })
          .catch(() => {});
      });
      $("#conList").on("click", "button.BoolResult", function () {
        var _that = this;
        var thisCode = $(this).siblings("input")[0].classList.value;
        var formulaArr = [];
        var inputArr = $(".formulaTwo input");
        inputArr.each((index, item1) => {
          var formulaJson = {};
          formulaJson["code"] = item1.classList.value;
          formulaJson["value"] = item1.value * 1;
          formulaArr.push(formulaJson);
        });
        var result = {
          Token: that.token,
          attributeConfigCode: thisCode,
          attributes: formulaArr,
        };
        GetLogicResult(result)
          .then(function (res) {
            if (res.ErrorCode == 0) {
              var result = res.Result;
              $(_that).siblings("input").val(result);
            } else {
              Notify({ type: "danger", message: res.ErrorMsg });
            }
          })
          .catch(() => {});
      });
      $("#conList").on("click", "button.Scan", function () {
        var _that = this;
        that.scanCode = $(this).siblings("input")[0].classList.value;
        that.dataVal = JSON.parse($(this).attr("data-val"));
        that.showEquipType = that.dataVal;
        that.scanShow = true;
        that.scanType = 2;
        if (that.timer1) clearTimeout(that.timer1);
        that.timer1 = setTimeout(that.startRecognize, 1000);
      });

      $("#conList").on("click", "button.Date", function () {
        var _that = this;
        var dataFormat = $(_that)[0].getAttribute("data-val");
        if (dataFormat == "yyyy.MM.dd-yyyy.MM.dd") {
          return false;
          // var newTime = that.getTimeFormat("yyyy.MM.dd");
          // var newTime1 = that.getTimeFormat("yyyy.MM.dd", "addOne");
          // $(_that)
          //   .parent()
          //   .find("input")
          //   .val(newTime + "-" + newTime1);
        }else if(dataFormat == "MM.dd HH:mm"){
          var newTime = dayjs(new Date()).format('MM.DD HH:mm')
          $(_that).parent().find("input").val(newTime);
        } else {
          var newTime = that.getTimeFormat(dataFormat);
          $(_that).parent().find("input").val(newTime);
        }
      });
    },
    getTimeFormat(dataFormat, type) {
      var newTime = "";
      var nowTime = new Date();
      if (type == "addOne") {
        nowTime = new Date(nowTime.getTime() + 24 * 60 * 60 * 1000);
      }
      nowTime.setTime(nowTime.getTime());
      var year = nowTime.getFullYear();
      var month =
        nowTime.getMonth() + 1 < 10
          ? "0" + (nowTime.getMonth() + 1)
          : nowTime.getMonth() + 1;
      var date =
        nowTime.getDate() < 10 ? "0" + nowTime.getDate() : nowTime.getDate();
      var hours =
        nowTime.getHours() < 10 ? "0" + nowTime.getHours() : nowTime.getHours();
      var minutes =
        nowTime.getMinutes() < 10
          ? "0" + nowTime.getMinutes()
          : nowTime.getMinutes();
      if (dataFormat == "yyyy.MM.dd") {
        newTime = year + "." + month + "." + date;
      } else if (dataFormat == "yyyy-MM-dd") {
        newTime = year + "-" + month + "-" + date;
      } else if (dataFormat == "yyyy/MM/dd") {
        newTime = year + "/" + month + "/" + date;
      } else if (dataFormat == "yyyy.MM.dd HH:mm") {
        newTime = year + "." + month + "." + date + " " + hours + ":" + minutes;
      } else if (dataFormat == "yyyy-MM-dd HH:mm") {
        newTime = year + "-" + month + "-" + date + " " + hours + ":" + minutes;
      } else if (dataFormat == "yyyy/MM/dd HH:mm") {
        newTime = year + "/" + month + "/" + date + " " + hours + ":" + minutes;
      } else if (dataFormat == "HH:mm") {
        newTime = hours + ":" + minutes;
      } else if (dataFormat == "MM:dd HH:mm") {
        newTime = month + ":" + date + " " + hours + ":" + minutes;
      }
      return newTime;
    },
    getRecordReportData() {
      let vthis = this;
      var result = {
        pageModel: {
          Token: this.token,
          search: [this.treeNode.testID, this.recordCode],
        },
      };
      GetRecordReportData(result)
        .then((response) => {
          if (response.ErrorCode == 0) {
            console.log($(".listValue input"));
            var res = response.Result.rows;
            this.reason = response.Result.reason || "";
            this.state = response.Result.state;
            $.each(res, function (i, v) {
              $.each($(".listValue input"), function (ii, vv) {
                var that = this;
                let type = v.type;
                let dataval = $(that).attr("dataVal");

                // console.log(v.attributeCode, $(that).attr("dataCode"));
                if (v.attributeCode == $(that).attr("dataCode")) {
                  if (type == "Choose") {
                    $(that).val(v.attributeValue);
                  } else if (type == "Select") {
                    // if ($(that).attr("type") == "user") {
                    // $(that).val(v.userName);
                    if (dataval === "team") {
                      var result = { pageModel: { Token: vthis.token } };
                      GetClassUserSelectThree(result).then(function (response) {
                        var res = response.Result;
                        if (response.ErrorCode == 0) {
                          if (res && res.length > 0) {
                            vthis.singleColumns = res;
                            let obj = vthis.singleColumns.find(
                              (item) => item.value == v.attributeValue
                            );
                            if (obj) {
                              $(that).attr("dataId", obj.value);
                              $(that).val(obj.text);
                            }
                          }
                        }
                      });
                    } else {
                      $(that).val(v.attributeValue);
                    }
                  } else if (type == "PDF") {
                    $(that).val(v.attributeValue);
                    // $(that).attr("dataLine", v.line);
                  } else if (type == "Radio") {
                    console.log(v);
                    if (v.attributeValue === "/") {
                      $(that).attr("dataId", v.attributeValue);
                      $(that).val("请选择");
                    }

                    // $(that).val(v.attributeValue);
                  } else {
                    $(that).val(v.attributeValue);
                  }
                  $(that).attr("dataIautoid", v.iautoid);
                }
              });
            });
          }
        })
        .catch(() => {});
    },
    showItemPopup() {
      this.showItem = true;
    },
    onConfirm() {
      this.showItem = false;
    },
    cancel() {
      this.showItem = false;
      this.checkBoxArr = [];
      this.checkedAll = false;
    },
    getTestId() {
      var params = {
        pageModel: {
          Search: [this.quote_materialCode, this.quote_batchID],
          Token: this.token,
        },
      };
      getReportId(params)
        .then((response) => {
          if (response.ErrorCode == "0") {
            var res = response.Result;
            var dataArr = [];
            res.map((item) => {
              dataArr.push({
                value: item.testID,
                text: item.testID,
              });
            });
            this.testList = dataArr;
          }
        })
        .catch(() => {});
    },
    onConfirmTest(val) {
      this.quote_testID = val.value;
      this.showTest = false;
    },
    closePopup() {
      var checkStr = "",
        num = "";
      if (this.checkBoxArr.length > 0) {
        num = this.checkBoxArr.length;
        checkStr = this.checkBoxArr.toString();
      }
      $("[dataCode=" + this.dataCode + "]").attr("dataL", checkStr);
      $("[dataCode=" + this.dataCode + "]").val("已选中" + num + "项");
      // var htlArr = $("#conList").find(".multSelect");
      // if (htlArr.length > 0) {
      //   $.each(htlArr, function (i, v) {
      //     var code = v.attributes[2].value;
      //     $("[dataCode=" + that.dataCode + "]").attr("dataL", checkStr);
      //     $("[dataCode=" + that.dataCode + "]").val("已选中" + num + "项");
      //   });
      // }
    },
    toggleAll() {
      this.$refs.checkboxGroup.toggleAll(this.checkedAll);
    },
    onConfirmSingle(value) {
      if (value.value) {
        $("[dataCode=" + this.dataCode + "]").attr("dataId", value.value);
        $("[dataCode=" + this.dataCode + "]").val(value.text);
      } else {
        $("." + this.dataCode).val(value);
      }

      this.showSingle = false;
    },
    getAddTestData() {
      if (this.recordCode == "") {
        Notify({ type: "danger", message: "请选择检验记录" });
        return false;
      }
      var result = {
        pageModel: {
          Token: this.token,
          search: [this.mCode, this.recordCode],
        },
      };
      GetRecordReportDataTwo(result)
        .then((response) => {
          if (response.ErrorCode == 0) {
            var res = response.Result;
            $.each(res, function (i, v) {
              $.each($(".listValue input"), function (ii, vv) {
                var that = this;
                if (v.attributeCode == $(that).attr("dataCode")) {
                  if (v.type == "Choose") {
                    $(that).val(v.attributeValue);
                  } else if (v.type == "Select") {
                    if ($(that).attr("type") == "user") {
                      $(that).val(v.userName);
                    } else {
                      $(that).val(v.attributeValue);
                      // $(that).attr("dataUser", v.attributeValue);
                    }
                  } else if (v.type == "PDF") {
                    $(that).val(v.attributeValue);
                    // $(that).attr("dataLine", v.line);
                  } else if (v.type == "Radio") {
                    $(that).val(v.attributeValue);
                  } else {
                    $(that).val(v.attributeValue);
                  }
                  $(that).attr("dataIautoid", v.iautoid);
                  $(that).attr("dataStandardCode", v.standardCode);
                }
                // if (v.attributeCode == $(that).attr("data-code")) {
                //   if (v.type == "Choose") {
                //     var vArr = v != "" ? v.attributeValue.split(",") : [];
                //     $(that).multiselect("select", vArr).multiselect("refresh");
                //   } else if (v.type == "Radio") {
                //     $(that).val(v.attributeValue).change();
                //   } else if (v.type == "Select") {
                //     if ($(that).attr("type") == undefined) {
                //       $(that).val(v.attributeValue).change();
                //     } else {
                //       $(that).val(v.userName);
                //       $(that).attr("data-user", v.attributeValue);
                //     }
                //   } else if (v.type == "PDF") {
                //     $(that).val(v.attributeValue);
                //     $(that).attr("data-line", v.line);
                //   } else {
                //     $(that).val(v.attributeValue);
                //   }
                //   // $(that).attr('data-id', v.iautoid)
                //   $(that).attr("data-standardCode", v.standardCode);
                // }
              });
            });
          }
        })
        .catch(() => {});
    },
    getPDF() {
      if (this.recordCode == "") {
        Notify({ type: "danger", message: "请选择检验记录" });
        return false;
      }
      var $PDF = $("input[name=PDF]");
      if ($PDF.length == 0) {
        Notify({ type: "danger", message: "无可递交检验项目" });
        return false;
      }
      this.PDFShow = true;
      this.getPDFList();
    },
    getPDF1() {
      if (this.recordCode == "") {
        Notify({ type: "danger", message: "请选择检验记录" });
        return false;
      }
      this.pdfh5 = null;
      this.getPDFList1();
    },
    editData() {
      var pNodes = document.getElementById("conList");
      var inputNodes = $(pNodes).find("input");
      inputNodes.map((index, item) => {
        // if (!item.className.includes("Select")) {

        // }
        if (item.value == "") {
          item.value = "/";
        }
      });
    },
    saveItemData() {
      var that = this;
      var submitData = [];
      var pNodes = document.getElementById("conList");
      var inputNodes = $(pNodes).find("input");
      if (inputNodes.length == 0) {
        return false;
      }

      inputNodes.map((index, a) => {
        var subDataObj = {};
        var name = a.getAttribute("name");
        if (name == "Select") {
          subDataObj["attributeCode"] = a.getAttribute("datacode");
          subDataObj["attributeValue"] = a.value;
          subDataObj["iautoid"] = a.getAttribute("dataiautoid");
        } else if (name == "Choose") {
          subDataObj["attributeCode"] = a.getAttribute("datacode");
          subDataObj["attributeValue"] = a.getAttribute("datal");
          subDataObj["iautoid"] = a.getAttribute("dataiautoid");
        } else if (name == "Radio") {
          subDataObj["attributeCode"] = a.getAttribute("datacode");
          subDataObj["attributeValue"] = a.getAttribute("dataId");
          subDataObj["iautoid"] = a.getAttribute("dataiautoid");
        } else {
          subDataObj["attributeCode"] = a.classList.value;
          subDataObj["attributeValue"] = a.value;
          subDataObj["iautoid"] = a.getAttribute("dataiautoid");
        }
        submitData.push(subDataObj);
      });
      var result = {
        Token: this.token,
        testID: this.treeNode.testID,
        batchID: this.batchID,
        recordCode: this.recordCode,
        recordReportData: submitData,
      };
      SaveRecordReportData(result)
        .then(function (res) {
          if (res.ErrorCode == 0) {
            that.handleItem();
            Notify({ type: "success", message: res.ErrorMsg });
          } else {
            Notify({ type: "danger", message: res.ErrorMsg });
          }
        })
        .catch(() => {});
    },
    submitItemData() {
      var that = this;
      var pNodes = document.getElementById("conList");
      var inputNodes = $(pNodes).find("input");
      var isWrite = false;
      inputNodes.map((index, a) => {
        if (
          a.getAttribute("dataiautoid") == "" ||
          a.getAttribute("dataiautoid") == null
        ) {
          isWrite = true;
        }
      });
      if (isWrite) {
        Notify({ type: "warning", message: "请全部填写保存后,在递交" });
        return false;
      }
      var result = {
        Token: this.token,
        testID: this.treeNode.testID,
        recordCode: this.recordCode,
      };
      SubmitRecordApprove(result)
        .then((response) => {
          if (response.ErrorCode == 0) {
            that.itemHtm = "";
            $("#recordPdf").html("");
            this.pdfUrl = "";
            Notify({ type: "success", message: response.ErrorMsg });

            // that.mCode = "";
            // that.materialName = "";
            // that.batchID = "";
            // that.standardBaseOn = "";
            // that.options = [];
            // that.recordName = "";
            // that.recordCode = "";
          }else{
            Notify({ type: "danger", message: response.ErrorMsg });
					}
        })
        .catch(() => {});
    },
    openScan(val) {
      this.scanShow = true;
      this.scanType = val;
      this.timer = setTimeout(this.startRecognize, 500);
    },
    startRecognize() {
      var that = this;
      that.timer = null;
      that.timer1 = null;
      if (!window.plus) return;
      scan = new plus.barcode.Barcode("bcid");
      scan.onmarked = onmarked;
      scan.start();
      function onmarked(type, result, file) {
        switch (type) {
          case plus.barcode.QR:
            type = "QR";
            break;
          case plus.barcode.EAN13:
            type = "EAN13";
            break;
          case plus.barcode.EAN8:
            type = "EAN8";
            break;
          default:
            type = "其它" + type;
            break;
        }
        result = result.replace(/\n/g, "");
        scan.close();
        that.scanShow = false;

        if (that.scanType == 2) {
          var str = decodeURIComponent(result);
          var strObj = JSON.parse(str);
          var oldVal = $("." + that.scanCode).val();
          var newVal,
            newArr = [];
          if (
            that.showEquipType &&
            Array.isArray(that.showEquipType) &&
            that.showEquipType.length
          ) {
            that.showEquipType.map((item) => {
              newArr.push(strObj[item]);
            });
          }
          if (
            that.showEquipType &&
            Array.isArray(that.showEquipType) &&
            that.showEquipType.length
          ) {
            newVal = newArr.toString();
          }
          if (oldVal) {
            if (oldVal.includes(newVal)) {
              $("." + that.scanCode).val(oldVal);
              // Notify({ type: "warning", message: "该仪器已存在！" });
            } else {
              $("." + that.scanCode).val(oldVal + "," + newVal);
            }
          } else {
            $("." + that.scanCode).val(newVal);
          }
        } else if (that.scanType == 1) {
          that.getScanType(JSON.parse(result).testID);
        } else if (that.scanType == 3) {
          console.log(1, JSON.parse(result));
        }
      }
    },
    closeModel() {
      this.scanShow = false;
      if (!window.plus) return;
      scan.close();
    },
    async getScanType(id) {
      var params = {
        queryModel: {
          Code: id,
          Token: this.token,
        },
      };
      const [err, res] = await to(getTestByTestId(params));
      var toDetail = res.Result;
      this.sampleName = toDetail.batchID + "[" + toDetail.standardBaseOn + "]";
      this.mCode = toDetail.testID;
      this.materialName = toDetail.materialName;
      this.batchID = toDetail.batchID;
      this.standardBaseOn = toDetail.standardBaseOn;
      this.materialCode = toDetail.materialCode;
      this.testStandard = toDetail.testStandard;
      this.fetchItems();
      this.itemHtm = "";
      this.recordName = "";
      this.recordCode = "";
      $("#recordPdf").html("");
    },
    showModel(type) {
      if (type == "recordIcon") {
        if (this.itemShow == true) {
          this.itemShow = false;
        } else {
          this.itemShow = true;
        }
      } else if (type == "itemIcon") {
        if (this.recordShow == true) {
          this.recordShow = false;
        } else {
          this.recordShow = true;
        }
      }
    },
    async afterRead(data) {
      let param = new FormData(); //创建form对象
      param.append("txt_fileDocument", data.file);
      param.append("Token", this.token);
      param.append("type", "RecordEquipmentPDF");
      param.append("batchID", this.batchID);
      param.append("materialCode", this.materialCode);
      const [err, res] = await to(uploadEquipmentFile(param));
      this.attachmentId = res.Result.attachmentId;
      this.getPDFList();
    },
    async getPDFList() {
      var params = {
        Token: this.token,
        type: "RecordEquipmentPDF",
        batchID: this.batchID,
        materialCode: this.materialCode,
        recordCode: this.recordCode,
        referBatchID: "/",
      };
      // const [err, res] = await to(getEquipmentFileSelect(params));
      getEquipmentFileSelect(params)
        .then(function (res) {
          var result = res.Result;
          result.map((item) => {
            item.value = item.attachmentId;
            item.text = item.fileName;
          });
          this.pdfArr = result;
        })
        .catch(() => {});
    },
    async getPDFList1() {
      var params = {
        Token: this.token,
        testID: this.treeNode.testID,
        recordCode: this.recordCode,
      };
      // const [err, res] = await to(PreviewElectronicRecordReport(params));
      PreviewElectronicRecordReport(params)
        .then((res) => {
          if (res) {
            let targetPath = res.Result.path;
            this.previewPdfUrl = targetPath;
            this.PDFShow1 = true;
          }
        })
        .catch(() => {});
    },
    async delPdfList() {
      var _that = this;
      var params = {
        Token: _that.token,
        attachmentID: _that.attachmentId,
      };
      const [err, res] = await to(deleteEquipFile(params));
      if (this.pdfArr.length > 0) {
        this.pdfArr.map((item, index) => {
          if (item.value == _that.attachmentId) {
            _that.pdfArr.splice(index, 1);
            _that.attachmentId = "";
          }
        });
      }
    },
    showUploadPdf() {
      var _that = this;
      if (this.pdfArr.length > 0) {
        this.pdfArr.map((item, index) => {
          if (item.value == _that.attachmentId) {
            var fileUrl = item.fileUrl;
            _that.pdfh5 = true;
            _that.$nextTick(() => {
              this.uploadPdfUrl = fileUrl
            });
          }
        });
      }
      var htm = "";
      this.itemDataArr.map((item) => {
        if (item.type == "PDF") {
          htm +=
            "<div class='listDetail insideList'><div class='pdfTitle'><input type='checkbox' checked>" +
            item.wordCode +
            ":" +
            item.name +
            "</div>";
          htm +=
            "<div class='listValue popupPdf'>值：<input  name='PDF' class=" +
            item.code +
            " type='text' ></div>";
          htm += "</div>";
        }
        this.pdfHtm = htm;
      });
    },
    async getPdfData() {
      if (this.attachmentId == "") {
        Notify({ type: "danger", message: "请选择PDF文件" });
        return false;
      }
      if ($("#conList [name=PDF]").length == 0) {
        Notify({ type: "danger", message: "无可取值的pdf项目" });
        return false;
      }
      var pdfArr = [];
      var selectArr = [];
      var pdfSelect = $(".pdfTitle");
      var ischecked = false;
      $.each(pdfSelect, function (i, v) {
        if (v.childNodes[0].checked) {
          ischecked = true;
          var pdfJson = {
            attributeValue: "",
          };
          pdfJson["attributeCode"] =
            v.nextSibling.childNodes[1].classList.value;
          pdfArr.push(pdfJson);
          selectArr.push(v.nextSibling.childNodes[1]);
        }
      });
      if (!ischecked) {
        Notify({ type: "danger", message: "请勾选PDF项目" });
        return false;
      }
      var params = {
        Token: this.token,
        attachmentID: this.attachmentId,
        pdfAttributes: pdfArr,
      };
      const [err, res] = await to(getConfigAttributesText(params));
      var result = res.Result.data;
      $.each(selectArr, function (i, v) {
        var that = this;
        $.each(result, function (i1, v1) {
          if (v1.attributeCode == that.classList[0]) {
            $(that).val(v1.attributeValue);
          }
        });
      });
    },
    assignPdfData() {
      $.each($(".pdfTitle"), function (i, v) {
        var that = this;
        var thatCheck = $(this).find("input:eq(0)").prop("checked");
        if (thatCheck) {
          $.each($(".mainPdf"), function (i1, v1) {
            if (
              $(this)[0].childNodes[1].classList.value ==
              $(that)[0].nextSibling.childNodes[1].classList.value
            ) {
              $(this)[0].childNodes[1].value =
                $(that)[0].nextSibling.childNodes[1].value;
            }
          });
        }
      });
      this.PDFShow = false;
      Notify({ type: "success", message: "赋值成功" });
    },
    //引用
    quoteData() {
      // this.$router.push({
      //   name: "recordQuote",
      //   params: {
      //     paramData: JSON.stringify(this.treeNode),
      //     recordName: this.recordName,
      //   },
      // });
      if (this.recordCode == "") {
        Notify({ type: "danger", message: "请选择检验记录" });
        return false;
      }
      this.showQuote = true;
    },
    handleSearch() {
      var _this = this;
      var params = {
        TestID: this.quote_testID,
        RecordName: this.recordName,
        Token: this.token,
      };
      GetAttributeValue(params)
        .then((response) => {
          if (response.ErrorCode == "0") {
            var res = response.Result;
            if (res && res.length) {
              _this.quoteDataArr = res;
              _this.showBtn = true;
              var htm = "";
              res.map((item) => {
                htm +=
                  "<li>" +
                  item.attributeName +
                  " : " +
                  item.attributeValue +
                  "</li>";
              });
              _this.liHtml = htm;
            }
          }
        })
        .catch(() => {});
    },
    handleSave() {
      $.each(this.quoteDataArr, function (i, v) {
        $.each($(".listValue input"), function (ii, vv) {
          var that = this;
          if (v.attributeCode == $(that).attr("dataCode")) {
            if (v.type == "Choose") {
              $(that).val(v.attributeValue);
            } else if (v.type == "Select") {
              if ($(that).attr("type") == "user") {
                $(that).val(v.userName);
              } else {
                $(that).val(v.attributeValue);
                // $(that).attr("dataUser", v.attributeValue);
              }
            } else if (v.type == "PDF") {
              $(that).val(v.attributeValue);
              // $(that).attr("dataLine", v.line);
            } else if (v.type == "Radio") {
              $(that).val(v.attributeValue);
            } else {
              $(that).val(v.attributeValue);
            }
            $(that).attr("dataIautoid", v.iautoid);
          }
        });
      });
      this.quote_materialCode = "";
      this.quote_batchID = "";
      this.quote_testID = "";
      this.quoteDataArr = [];
      this.liHtml = "";
      this.showQuote = false;
      this.showBtn = false;
    },
  },
  created() {
    this.treeNode = JSON.parse(this.$route.query.paramData);
    console.log("this.treeNode", this.treeNode);
    this.mCode = this.treeNode.code;
    this.sampleName = this.treeNode.name;
    this.mCode = this.treeNode.code;
    this.materialName = this.treeNode.materialName;
    this.batchID = this.treeNode.batchID;
    this.standardBaseOn = this.treeNode.standardBaseOn;
    this.materialCode = this.treeNode.materialCode;
    this.testStandard = this.treeNode.testStandard;
  },
};
</script>
<style>
.van-nav-bar__title {
  color: #fff;
}
.van-icon-arrow-left {
  color: #fff !important;
}
.van-cell__title {
  text-align: left;
  font-weight: 500;
}
.van-button--small {
  height: 0.65rem;
}
.cd-content {
  padding: 0.2rem 0.1rem;
  color: #000;
  font-size: 0.36rem;
  height: 100%;
  display: flex;
  flex-wrap: nowrap !important;
}
.cd-content > .van-col:first-child {
  margin-right: 10px;
}
.cd-content > .van-col {
  height: 100%;
  width: 100%;
  /* overflow-y: auto; */
  border: 1px solid #49bbef;
}
.van-dropdown-menu__bar {
  box-shadow: 0 0 0;
  height: 36px;
}
#conList {
  width: 100%;
  height: calc(100% - 0.8rem);
  overflow-y: auto;
}
.cd-content > .van-col > .title {
  display: flex;
  justify-content: space-between;
  align-content: center;
  height: 0.8rem;
  line-height: 0.8rem;
  background-color: #49bbef;
  color: #fff;
  padding: 0 0.2rem;
}
.recordIcon,
.itemIcon {
  line-height: 0.8rem;
  display: flex;
  align-items: center;
}
#recordPdf,
#uploadPdf,
#uploadPdf1 {
  width: 100%;
  height: calc(100% - 0.8rem);
}
.listDetail {
  padding: 0.2rem;
  border-bottom: 1px solid #ccc;
}
.listDetail input {
  height: 0.6rem;
  width: 100%;
  display: inline-block;
  border: 1px solid #ccc;
  box-sizing: border-box;
}
.listDetail input[name="Weight"] {
  background: #ccc;
}
.listDetail input[type="checkbox"] {
  width: 12px;
  height: 12px;
}
.listDetail span {
  display: inline-block;
  height: 0.6rem;
  width: 20%;
  text-align: center;
  border: 1px solid #ccc;
  border-left: none;
  box-sizing: border-box;
  line-height: 0.6rem;
}
.listDetail button {
  height: 0.6rem;
  width: 30%;
  text-align: center;
  border: 1px solid #ccc;
  border-left: none;
  box-sizing: border-box;
  line-height: 0.6rem;
}
.listValue {
  display: flex;
  align-content: center;
}
.van-dropdown-menu__title {
  font-size: 0.36rem;
}
</style>
<style scoped lang="less">
.configDetail {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-y: auto;
  // color: #fff;
}
.nav-bar {
  background-color: #49bbef;
}
.handleContent {
  width: 100%;
}
.van-col-style {
  font-size: 0.36rem;
  color: #000;
  text-align: left;
  padding-left: 0.2rem;
  margin-top: 0.2rem;
}
.van-col-btn {
  text-align: right;
  margin-right: 0.2rem;
}
.van-row-style {
  padding: 0.2rem 0;
  border-bottom: 1px solid #ddd;
}
.select-record {
  padding: 0;
}

pdf {
  width: 100%;
  height: 500px;
  overflow-y: auto;
}
.scan {
  height: 100%;
  width: 100%;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;

  #bcid {
    width: 100%;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 1rem;
    text-align: center;
    color: #fff;
    background: #ccc;
    font-size: 20px;
    z-index: 999;
    .closeModel {
      position: absolute;
      top: 20px;
      right: 20px;
    }
  }
  footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    bottom: 0;
    height: 1rem;
    font-size: 20px;
    button {
      height: 100%;
      width: 100%;
      border: none;
    }
  }
  /deep/.van-cascader__options {
    height: auto !important;
  }
}
/deep/.van-popup {
  overflow-y: hidden;
}
.checkbox-con {
  height: calc(100% - 1.2rem);
}
.readonly /deep/.van-field__body {
  background: #ddd;
}
/deep/.van-cell {
  padding: 0.2rem 0.4rem;
}
/deep/.van-field__body {
  border-radius: 2px !important;
  border: 1px solid #ddd;
}
/deep/.van-cell {
  font-size: 0.32rem;
}
/deep/.van-cascader__header {
  height: 1rem;
}
/deep/.van-cascader__tabs.van-tabs--line .van-tabs__wrap {
  height: 1rem;
}
.popup-content__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px;
  .title {
    font-size: 20px;
    font-weight: bold;
  }
}
.popup-content__footer {
  padding: 10px 15px;
  font-size: 16px;
  box-sizing: border-box;
  ul {
    width: 100%;
    border: 1px solid #ccc;
    min-height: 100px;
    max-height: 300px;
    overflow: auto;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 5px;
  }
}
</style>
